<?php

class Application_Model_Statussupplier extends Zend_Db_Table_Abstract
{
    protected $_name = 'tabel_status_supplier';
    
    public function statusSupplierBaru($statussupplier, $keterangan)
    {
        $data = array('status_supplier' => $statussupplier, 'keterangan_status_supplier' => $keterangan);
        $this->insert($data);
    }
    
    public function getStatusSupplier($id) {
        $id = (int)$id;
        $row = $this->fetchRow('id_status_supplier = '.$id);
        if(!$row)
            throw  new Exception('Data dengan id=$id tidak ditemukan');
        else
            return $row->toArray ();
    }
    
    public function statusSupplierUpdate($id, $statussupplier, $keterangan)
    {
        $this->update(array('status_supplier' => $statussupplier, 'keterangan_status_supplier' => $keterangan), 'id_status_supplier = '.(int)$id);   
    }
    
    public function statusSupplierDelete($id){
        $this->delete('id_status_supplier = '.(int)$id);
    }

    public function checkStatusSupplier($nama) {
        $select = $this->select();
        $select->where("status_supplier= ?",$nama);
        $row = $this->fetchAll($select)->count();
        if($row > 0)
            return true;
        else
            return false;
    }
    
    public function  getAllData()
    {
        $data = $this->fetchAll()->toArray();
        return $data;
    }
    
    public function checkRowStatusSupplier()
    {
        $row = $this->fetchAll()->count();
        return $row;
    }

}

